<template>
  <!-- 未绑定首页 -->
  <div class="page">
    <hasbind
      v-if="hasBindData != undefined"
      :data="hasBindData"
    />
    <unbind v-else />
  </div>
</template>

<script>
import { readStudentWX, fetchDictList } from "../../api/person";

export default {
  components: {
    unbind: () => import("@/views/personinfo/personinfo-unbind"),
    hasbind: () => import("@/views/personinfo/personinfo-hasbindbusiness.vue"),
  },
  data() {
    return {
      hasBindData: undefined,
      wxuid: undefined,
    };
  },
  created() {},
  mounted() {
    this.wxuid = sessionStorage.getItem("wxUserId");
    this.netReadStudent();
    this.netFetchDictList();
  },
  methods: {
    netReadStudent() {
      let fi = { wxUserId: this.wxuid };
      let self = this;
      readStudentWX(fi)
        .then((res) => {
          if (res.data.id == undefined) {
            self.hasBindData = undefined;
          } else {
            self.hasBindData = res.data;
          }
        })
        .catch((e) => {
          console.error("*******************");
          console.error(e);
          console.error("*******************");
        });
    },
    netFetchDictList() {
      let self = this;
      fetchDictList().then((res) => {
        let { data, code, msg } = res;
        if (code == 200) {
          console.warn("vvvvvvfetchDictListvvvvv");
          global.dictList = data;
        } else {
          self.$toast(msg);
        }
      });
    },
  },
};
</script>

<style scoped>
.page {
  background-color: #ffffff;
  flex: 1;
  display: flex;
  flex-direction: column;
}
</style>
